package com.cskaoyan._02method._03methodcases;

import java.util.Scanner;

/**
 * @author Macro_Ray
 * @since 2024/3/5 19:40
 */
/* 机票价格按照淡季旺季、头等舱和经济舱收费，输入机票原价、月份和头等舱或经济舱。
 * 按照如下规则计算机票价格:旺季(5-10月)头等舱9折，经济舱8.5折，淡季(11月到来年4月)头等舱7折，经济舱6.5折。*/
public class _01Test_01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (; ; ) {
            // 输入机票原价、月份和头等舱或经济舱
            System.out.println("请输入机票原价：");
            double piece = sc.nextInt();
            System.out.println("请输入月份：");
            int month = sc.nextInt();
            sc.nextLine();
            System.out.println("头等舱还是经济舱：");
            String whichOne = sc.nextLine();

            int cabin = 0; // 默认为0，表示经济舱

            if (whichOne.equals("头等舱")) {
                cabin = 1; // 设置为1，表示头等舱
            }

            if (month > 0 && month <= 12) {
                if (month >= 5 && month <= 10) {
                    if (cabin == 0) {
                        piece = piece * 0.85;
                        System.out.println("机票的价格是：" + piece);
                        break;
                    } else {
                        piece = piece * 0.9;
                        System.out.println("机票的价格是：" + piece);
                        break;
                    }
                } else {
                    if (cabin == 0) {
                        piece = piece * 0.65;
                        System.out.println("机票的价格是：" + piece);
                        break;
                    } else {
                        piece = piece * 0.7;
                        System.out.println("机票的价格是：" + piece);
                        break;
                    }
                }
            } else {
                System.out.println("月份输入异常，请重试");
            }
        }
    }
}
